/*
 * PlaylistPopupMenu.java
 *
 * Created on April 8, 2006, 2:04 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package com.bff.slimserver.musicjukebox.ui.components;

import com.bff.slimserver.musicjukebox.lib.actions.AddFavoriteAction;
import com.bff.slimserver.musicjukebox.lib.actions.DisplaySongInfoAction;
import com.bff.slimserver.musicjukebox.lib.actions.PlaySongAction;
import com.bff.slimserver.musicjukebox.lib.actions.PlaylistRemoveSongAction;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.bff.slimserver.SlimPlaylist;
import org.bff.slimserver.musicobjects.SlimPlaylistItem;
import org.bff.slimserver.musicobjects.SlimSong;

/**
 *
 * @author Bill
 */
public class PlaylistPopupMenu extends JPopupMenu {

    private SlimPlaylist playlist;
    private JMenuItem playSongMenuItem;
    private JMenuItem removePlaylistMenuItem;
    private JMenuItem displaySongInfoMenuItem;
    private JMenuItem addFavMenuItem;

    private SlimPlaylistItem object;
    private JFrame parent;

    /** Creates a new instance of PlaylistPopupMenu */
    public PlaylistPopupMenu(JFrame parent,
            SlimPlaylist playlist,
            SlimPlaylistItem object) {
        this.playlist = playlist;
        this.object = object;
        this.parent = parent;
        createMenuItems();
    }

    private void createMenuItems() {
        //current playlist
        playSongMenuItem = new JMenuItem(new PlaySongAction(playlist, object));
        add(playSongMenuItem);

        //remove from playlist
        removePlaylistMenuItem = new JMenuItem(new PlaylistRemoveSongAction(playlist, object));
        add(removePlaylistMenuItem);

        addFavMenuItem = new JMenuItem(new AddFavoriteAction(object));
        add(addFavMenuItem);

        if (object instanceof SlimSong) {
            displaySongInfoMenuItem = new JMenuItem(new DisplaySongInfoAction(parent, object));
            add(displaySongInfoMenuItem);
        }

    }
}
